<?php
include 'bd.php';
include 'sessao.php';

class Funcionario{
	var $users;
	var $senha;
	var $id;
	function pesquisarUsuario($usuario,$pass){
		$query="select * from usuarios where nick_user='$usuario' and senha_user='$pass'";
		$result=mysql_query($query);
		while($query=mysql_fetch_array($result)){
		$this->usuario=$query['nick_user'];
		$this->users=$query['nome_user'];
		$this->senha=$query['senha_user'];
		$this->id=$query['id_user'];
		}
		$result=mysql_num_rows($result);
		return $result;
		}
}


function pesquisarSistema(){
	$query = "select id_sis,nome_sis from sistema";
	$result=mysql_query($query);
	while($query = mysql_fetch_array($result)){
		echo "<option value=".$query['id_sis'].">".$query['nome_sis']."</option>";
	}
}

function pesquisarMeioAtendimento(){
	$query ="select id_atendi,tipo_atendi from meioAtendimento";
	$result = mysql_query($query);
	while($query = mysql_fetch_array($result)){
		echo "<input type=".'radio'. " name=".'meioAtendimento'." value=".$query['id_atendi']." required='required' />".$query['tipo_atendi']." ";
	}	
}

function pesquisarMeioComunicacao(){
	$query="select * from meiocomunicacao";
	$result=mysql_query($query);
	while($query=mysql_fetch_array($result)){
		echo "<option value=".$query['id_comu'].">".$query['nome_comu']."</option>";
	}
}

function contarNumeroAtendimentos(){
	$query ="select id_atendi,tipo_atendi from meioAtendimento";
	$result=mysql_query($query);
	$i=1;
	while($value=mysql_fetch_array($result)){
		$temp="select count(*) from historico where id_atendi=".$i;
		$result2=mysql_query($temp);
		$temp=mysql_fetch_array($result2);	
		echo "<span>".$value['tipo_atendi'].":</span> ".$temp[0]. "<br />";
		++$i;
	}
}

function contarComoConheceu(){
	$query ="select id_comu,nome_comu from meiocomunicacao";
	$result=mysql_query($query);
	$i=1;
	while($value=mysql_fetch_array($result)){
		$temp="select count(*) from historico where id_comu=".$i;
		$result2=mysql_query($temp);
		$temp=mysql_fetch_array($result2);	
		echo "<span>".$value['nome_comu'].":</span> ".$temp[0]. "<br />";
		++$i;
	}
}

function selecionarEmAberto(){
	$query="select * from historico where status='Em aberto' and id_user=".$_SESSION['id'];
	$result=mysql_query($query);
	echo "<article><h2>Problemas/Duvidas de clientes a serem resolvidos</h2><br />";
	while($query=mysql_fetch_array($result)){
		echo "<span>Data/Hora atendimento: </span><span id='infoContatos'>".$query['data_criacao']."</span><br />";	
		echo "<span>Data/Hora marcado: </span><span id='infoContatos'>".$query['data_marcada']."</span><br />";
		echo "<span>Observacao: </span> <span id='infoContatos'>".$query['obs']."</span><br />";	
		echo "<br /><details>".$query['obs']."</details>";
		echo "<br /><br />";
	}
	echo "</article>";
}

function selecionarPotenciaisClientes(){
	$query="select * from historico where interesse=1";
	$result=mysql_query($query);
	while($query=mysql_fetch_array($result)){
		echo "<span>Nome do Cliente:</span> <span id='infoContatos'>".$query['nome_atend']."</span><br />";
		echo "<span>E-mail: </span> <span id='infoContatos'>".$query['contato_atend']."</span><br />";
		echo "<span>Telefone: </span> <span id='infoContatos'>".$query['telefone_atend']."</span><br />";
		echo "<br /><details>".$query['obs']."</details>";
		echo "<br /><br />";	
	}
}

?>